using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeInstance:System.ICloneable, IInGameInfo {

	public UpgradeData upgradeData;
	public Dictionary<string,object> extraData;
	public bool activated;

	public void Activate() { activated=true; }
	public void Deactivate() { activated=false; }

	public string name => upgradeData.name;
	public string description => descr;
	public string descr {
		get {
			string additional = upgradeData.instanceAdditional;
			if(extraData.Count==0) additional="";
			foreach(var i in extraData) {
				if(additional.Contains($"{{{i.Key}}}"))
					additional=additional.Replace($"{{{i.Key}}}",i.Value.ToString());
			}
			additional=additional.TrimStart();
			if(additional.Length>0) return upgradeData.description+"\n"+additional;
			return upgradeData.description;
		}
	}
	public int cost => upgradeData.cost;

	public bool locked;

	public UpgradeInstance(UpgradeData upgradeData) {
		this.upgradeData=upgradeData;
		extraData=new Dictionary<string,object>();
	}

	object System.ICloneable.Clone() {
		UpgradeInstance result = new UpgradeInstance(upgradeData);
		result.extraData=new Dictionary<string,object>(extraData);
		return result;
	}

}